package com.godpaper.as9.commands
{
	import assets.EmbeddedAssets;
	
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	import com.godpaper.as9.bussiness.delegates.ClassDelegate;
	import com.godpaper.as9.events.TryCreateClassEvent;
	import com.godpaper.as9.model.ClassModelLocator;
	
	import mx.controls.Alert;
	import mx.rpc.IResponder;

	public class TryCreateClassCommmand extends CommandBase implements ICommand, IResponder
	{
		private var delegate:ClassDelegate;
		private var tryCreateClassEvent:TryCreateClassEvent;
		private var classModel:ClassModelLocator = ClassModelLocator.getInstance();
		public function TryCreateClassCommmand()
		{
			super();
			delegate = new ClassDelegate(this);
		}
		
		override public function execute(event:CairngormEvent):void
		{
			tryCreateClassEvent = TryCreateClassEvent(event);
			delegate.create([tryCreateClassEvent.simpleClass.name,tryCreateClassEvent.simpleClass.description]);
		}
		
		override public function result(data:Object):void
		{
//			trace(data.result.info);
			if(data.result.info=="success")
			{
				Alert.show("创建班级成功!","",4,null,null,EmbeddedAssets.ALERT_INFO);
			}else
			{
				Alert.show(data.result.detail,data.result.info,4,null,null,EmbeddedAssets.ALERT_WARNNING);
			}
		}
		
	}
}